<?php

namespace common\models\order;

use common\models\BaseModel;

/**
 * Desc 订单管理模型
 */
class OrderModel extends BaseModel
{

    /** 状态: 待支付 */
    const STATE_WAIT_PAY = 1;
    /** 状态: 待发货 */
    const STATE_WAIT_DELIVERY = 2;
    /** 状态: 待收货 */
    const STATE_WAIT_RECEIVE = 3;
    /** 状态: 已收货 */
    const STATE_RECEIVED = 4;
    /** 状态: 已取消 */
    const STATE_CANCEL = 5;
    /** 状态: 已退款 */
    const STATE_REFUND = 6;
    /** 状态: 退款中 */
    const STATE_REFUNDING = 7;

    //订单超时时间
    const CANCEL_ORDER_MINITUE = 60 * 30;

    //订单HOLD时间
    const HOLD_ORDER_MINITUE = 60 * 2;

    // 订单状态
    public static $state = [
        self::STATE_WAIT_PAY => '待支付',
        self::STATE_WAIT_DELIVERY => '待发货',
        self::STATE_WAIT_RECEIVE => '待收货',
        self::STATE_RECEIVED => '已收货',
        self::STATE_CANCEL => '已取消',
        self::STATE_REFUND => '已退款',
        self::STATE_REFUNDING => '退款中',
    ];

    /** 支付: 微信小程序 */
    const PAY_WEIXIN_MINI = 1;
    /** 支付: 支付宝小程序 */
    const PAY_ALIPAY_MINI = 2;
    /** 支付: 现金 */
    const PAY_CASHE = 3;
    /** 支付: 余额 */
    const PAY_BALANCE = 4;
    // 支付方式
    public static $pay_way = [
        self::PAY_WEIXIN_MINI => '微信支付',
        self::PAY_ALIPAY_MINI => '支付宝',
        self::PAY_CASHE => '现金',
        self::PAY_BALANCE => '余额',
    ];

    /**
     * {@inheritdoc}
     */
    public static function tableName()
    {
        return '{{%order}}';
    }
}
